#ifndef USERMODEL_H
#define USERMODEL_H

#include <QObject>
#include <QAbstractListModel>
#include "database/databasequery.h"

class UserModel:public QAbstractListModel
{
public:
    UserModel(int colCnt,const QString& showName,QObject* parent);
    ~UserModel();
    enum{
        ROLE_NAME = Qt::UserRole,
        ROLE_ID,
        ROLE_PERMISION,
        ROLE_PASSWORD
    };
    enum permision
    {
        TECH = 0,
        ADMIN = 1,
        OPERATOR
    };
    static int checkPasswd(const QString &name, const QString &passwd);
    QString getTabName(){return mTabName;}
    QString getColumnName(){return mColumnName;}

public slots:
    virtual bool submit();
    virtual bool submitFilter(const QString &str);

    // QAbstractItemModel interface
public:
    int rowCount(const QModelIndex &parent) const;
    int columnCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;
private:
    DataBaseQuery *mQuery;
    int mColumnCount;
    int mDataCount;
    QString mColumnName;
    QString mTabName;
};

#endif // USERMODEL_H
